How to Redirect your Website From HTTP to HTTPS by cPanel Hosting
Redirect your Website From HTTP to HTTPS by cPanel Hosting
If your website is hosted on cPanel, you can easily redirect your website from HTTP to HTTPS using the cPanel interface. Here's a step-by-step guide:
Step 1: First Install an SSL Certificate.
Before redirecting to HTTPS, you need to make sure that you have a valid SSL certificate installed on your website. Many hosting providers offer free SSL certificates through services like Let's Encrypt that you can redirect http to https completely.
Log in to your cPanel account. Look for the "SSL/TLS Status" or "SSL/TLS" section. This may vary slightly depending on your cPanel version and theme.
Find the option to install an SSL certificate, and follow the instructions to generate and install a free SSL certificate.
Step 2: Redirect HTTP to HTTPS.
In cPanel, locate the "File Manager" or "File Manager (Home Directory)" option. Navigate to the root directory of your website. This is typically the public_html folder.
Step 3: Look for a file named .htaccess. If you don't see it, you may need to create one. To create a new file, click on "File" in the top left corner, select "New File," and name it .htaccess or create.
Step 4: Right-click on the .htaccess file and choose "Edit" or "Code Edit." Add the following code to the file to redirect all HTTP traffic to HTTPS:
Step 5: Copy the below code and pest .htaccess file
Rewrite Engine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This code checks if the connection is not over HTTPS and redirects to the same URL with HTTPS. Save the changes.
Step 6: Test the Redirection. Open a new browser window and enter your website's URL using http:// (e.g., http://www.yourdomain.com).
Step7:Verify that the URL automatically redirects to https://www.yourdomain.com. If the redirection is working correctly, you should see the padlock icon indicating a secure connection.
Step 8: Update Links and Resources. Ensure that all the resources (images, stylesheets, scripts, etc.) on your website are loaded using the "https://" protocol. This is important to avoid "mixed content" warnings in browsers.
Step 9: Update Google Search Console and Analytics. If you use tools like Google Search Console or Google Analytics, update your settings to use the new HTTPS URLs.
That's it! Your website should now be successfully redirected from HTTP to HTTPS. Remember to always keep a backup of your .htaccess file before making changes, and if you encounter any issues, you can revert to the previous version.